From: Happy-melon Date: Sun, 20 Sep 2009 22:14:09 +0000 (+0000) Subject: (bug16979) Add tracking categories for __INDEX__ and __NOINDEX__. X-Git-Tag: 1.31.0-rc.0~39607 X-Git-Url: http://git.cyclocoop.org/%22.%24info%5B?a=commitdiff_plain;h=a25885d336ca06668d6e3de9eb43b80682262950;p=lhc%2Fweb%2Fwiklou.git (bug16979) Add tracking categories for __INDEX__ and __NOINDEX__. --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index de0437b098..e95dd3e9a3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -238,6 +238,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * A new permission, 'root', is created. Analogous to root users on Unix systems, the root permission effectively grants all other permissions on a wiki. Useful for debugging and administration. +* (bug 16979) Tracking categories for __INDEX__ and __NOINDEX__ === Bug fixes in 1.16 === diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 20af1c6a1a..9c8cae1b49 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -3332,25 +3332,39 @@ class Parser } if ( isset( $this->mDoubleUnderscores['hiddencat'] ) && $this->mTitle->getNamespace() == NS_CATEGORY ) { $this->mOutput->setProperty( 'hiddencat', 'y' ); - - $containerCategory = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( 'hidden-category-category' ) ); - if ( $containerCategory ) { - $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() ); - } else { - wfDebug( __METHOD__.": [[MediaWiki:hidden-category-category]] is not a valid title!\n" ); - } + $this->addTrackingCategory( 'hidden-category-category' ); } # (bug 8068) Allow control over whether robots index a page. # # FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This # is not desirable, the last one on the page should win. - if( isset( $this->mDoubleUnderscores['noindex'] ) ) { + if( isset( $this->mDoubleUnderscores['noindex'] ) && $this->mTitle->canUseNoindex() ) { $this->mOutput->setIndexPolicy( 'noindex' ); - } elseif( isset( $this->mDoubleUnderscores['index'] ) ) { + $this->addTrackingCategory( 'noindex-category' ); + } + if( isset( $this->mDoubleUnderscores['index'] ) && $this->mTitle->canUseNoindex() ){ $this->mOutput->setIndexPolicy( 'index' ); + $this->addTrackingCategory( 'index-category' ); } wfProfileOut( __METHOD__ ); return $text; + } + + /** + * Add a tracking category, getting the title from a system message, + * or print a debug message if the title is invalid. + * @param $msg String message key + * @return Bool whether the addition was successful + */ + protected function addTrackingCategory( $msg ){ + $containerCategory = Title::makeTitleSafe( NS_CATEGORY, wfMsgForContent( $msg ) ); + if ( $containerCategory ) { + $this->mOutput->addCategory( $containerCategory->getDBkey(), $this->getDefaultSort() ); + return true; + } else { + wfDebug( __METHOD__.": [[MediaWiki:$msg]] is not a valid title!\n" ); + return false; + } } /** diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index b70f684809..f8fff4f73c 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -735,6 +735,8 @@ XHTML id names. 'category-file-count' => '{{PLURAL:$2|This category contains only the following file.|The following {{PLURAL:$1|file is|$1 files are}} in this category, out of $2 total.}}', 'category-file-count-limited' => 'The following {{PLURAL:$1|file is|$1 files are}} in the current category.', 'listingcontinuesabbrev' => 'cont.', +'index-category' => 'Indexed pages', +'noindex-category' => 'Noindexed pages', 'linkprefix' => '/^(.*?)([a-zA-Z\\x80-\\xff]+)$/sD', # only translate this message to other languages if you have to change it 'mainpagetext' => "'''MediaWiki has been successfully installed.'''", diff --git a/languages/messages/MessagesQqq.php b/languages/messages/MessagesQqq.php index 1fcc1c5daa..f87b74397e 100644 --- a/languages/messages/MessagesQqq.php +++ b/languages/messages/MessagesQqq.php @@ -236,6 +236,8 @@ This is the toolbar: [[Image:Toolbar.png]]", * $1: number of files shown', 'listingcontinuesabbrev' => 'Shown in contiuation of each first letter group. See http://test.wikipedia.org/wiki/Category:Test_ko?uselang={{SUBPAGENAME}}, for example.', +'index-category' => 'Name of the category where pages with the __INDEX__ behaviour switch are listed', +'noindex-category' => 'Name of the category where pages with the __NOINDEX__ behaviour switch are listed', 'linkprefix' => '{{optional}}', 'mainpagetext' => 'Along with {{msg|mainpagedocfooter}}, the text you will see on the Main Page when your wiki is installed.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 4e73868e3d..b7ee9017b4 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -141,6 +141,8 @@ $wgMessageStructure = array( 'category-file-count', 'category-file-count-limited', 'listingcontinuesabbrev', + 'index-category', + 'noindex-category', ), 'mainpage' => array( 'linkprefix',